<template>
	<view>
		<titlebar mode="订单确认" :back="true" :text="text" :backgroundColor='backgroundColor' :color='color'>
			<view slot="title">
				<view class="titleText" :style='"color:" + color'>{{text}}</view>
			</view>
		</titlebar>

		<image class="top-img" mode="widthFix" :src="configurePic||'@appstatic/car/car_banner.jpg'" />

		<view class="orderInfo">


			<scroll-view :refresher-enabled='false' scroll-y show-scrollbar="false" style=" height: 100%;width: 100%;">
				<view class="info-transverse">
					<view class="test1">选购信息</view>
					<!-- <view v-if="from=='车辆配置'"> -->
					<view class="text2" v-if="wishId==''" @click="addWishList">加入心愿单</view>
					<view class="text11" v-else @click="deleteWishList">取消心愿单</view>
					<!-- </view> -->
				</view>
				<view class="line"></view>

				<view class="info-transverse">
					<view class="text3">车系</view>
					<view class="text4">{{seriesName}}</view>
				</view>
				<view class="info-transverse">
					<view class="text3">车型</view>
					<view class="text5">{{modelName}}</view>
				</view>
				<view class="info-transverse">
					<view class="text3">配置</view>
					<view class="text6">{{carConfigName}}<text class="before">￥{{carConfigMoney}}</text></view>
				</view>
				<view class="info-transverse">
					<view class="text3">颜色</view>
					<view class="text6">{{colorName}}<text class="before">￥{{colorMoney}}</text>
					</view>
				</view>



				<view v-if="servciepkgInfos.length>0" v-for="(item,index) in servciepkgInfos">

					<view class="info-transverse">
						<view class="text3">选装包</view>
						<view class="text6">{{item.serverName}}<text class="before">￥{{item.serverMoney}}</text></view>
					</view>

					<view class="info-list">
						<view v-for="(item1,index1) in item.packageDescribeList">
							<view class="text7">{{item1}}</view>
						</view>
					</view>
				</view>

				<view v-if="uniqueserverInfos.length>0" v-for="(item,index) in uniqueserverInfos">
					<view class="info-transverse">
						<view class="text3">个性化</view>
						<view class="text6">{{item.serverName}}<text class="before">￥{{item.serverMoney}}</text></view>
					</view>
					<view class="info-list">
						<view class="text7">{{item.uniqueContent}}</view>
					</view>

				</view>




				<view class="info-transverse">
					<view class="text3">总计</view>
					<view class="text8">￥{{totlePrice}}</view>
				</view>
				<!-- =======================新增 金融信息 ===========================-->
				 <view class="info-transverse">
					<view class="test1">金融信息</view>
				</view>
				<view class="line"></view>
				<view class="info-transverse">
					<view class="text3">购车方式</view>
					<radio-group name="" @change="payInput">
						<label v-for="item in identityPeyType" :key="item" style="margin-right:20px">
							<radio :value="item.value" :checked="item.value==paymentType" color="#EA5404"
								style="transform:scale(0.7)" />
							{{item.text}}
						</label>
					</radio-group>
				</view>
				<view class="info-list"  >
					<view class="text9">注：金融分期购买需提前与派方之家或官方客服联系，了解分期流程，进行资质审核</view>
				</view>
				<!-- ========================新增 金融信息 ======================-->
				<view class="info-transverse">
					<view class="test1">收货信息</view>
				</view>
				<view class="line"></view>
				<view class="info-transverse">
					<text class="text3">收货人</text>
					<input class="uni-text" type="text" value='name' v-model='name' data-type='name'
						@input='inputValueChange' placeholder="请输入姓名" placeholder-style="color:#ADB0AE" />
				</view>
				<view class="info-transverse">
					<text class="text3">电话</text>
					<input class="uni-text" type="number" value='mobile' v-model='mobile' data-type='mobile'
						maxlength="11" @input='inputValueChange' placeholder="请输入电话"
						placeholder-style="color:#ADB0AE" />
				</view>
				<view class="info-transverse">
					<text class="text3">身份证号</text>
					<input class="uni-text" type="idcard" value='idcard' v-model='idcard' data-type='idcard'
						maxlength="18" @input='inputValueChange' placeholder="请输入身份证号"
						placeholder-style="color:#ADB0AE" />
				</view>
				<view class="info-transverse" @click="toArea">
					<text class="text3">城市</text>
					<view class="right">
						<text class="text6" style="margin-right: 5px;">{{city}}</text>
						<image class="arrow" src="@appstatic/car/car_arrow_down.png">
					</view>
				</view>
				<view class="info-transverse" @click="showStoresData" v-if="haveStoresList==true">
					<text class="text3">交付门店</text>
					<view class="right">
						<text class="text6" style="margin-right: 5px;">{{storeName}}</text>
						<image class="arrow" src="@appstatic/car/car_arrow_down.png">
					</view>
				</view>
				<u-picker title="选择门店" :show="isShowStoresPicker" :columns="storesList" @confirm="confirmPicker"
					@cancel="cancelPicker" keyName="storeName" confirmColor="#EA5404"></u-picker>
				<view class="info-transverse-address">
					<text class="text3" style="width: 80px;margin-top: 5px;">收货地址</text>
					<textarea class="uni-text-address" type="text" value='address' v-model='address' data-type='address'
						maxlength="150" ref="textarea" @input='inputValueChange' placeholder="请输入详细地址"
						placeholder-style="color:#ADB0AE" auto-height />
				</view>
				<view class="info-list" v-show="false">
					<view class="text9">门店自提免费，送货上门额外收取 300 元服务费</view>
				</view>
				<view class="info-transverse">
					<view class="test1">支付信息</view>
				</view>
				<view class="line"></view>
				<!-- <view v-if="uniqueserverInfos.length==0"> -->
				<view class="info-transverse">
					<view class="text3">定金</view>
					<view class="text6">￥{{depositAmount}}</view>
				</view>
				<view class="info-transverse">
					<view class="text3">尾款</view>
					<view class="text6">￥{{balancePayment}}</view>
				</view>
				<!-- </view>
				<view v-else>
					<view class="info-transverse">
						<view class="text3">支付金额</view>
						<view class="text6">￥{{totlePrice}}</view>
					</view>
				</view> -->
				<!-- #ifdef APP-PLUS||H5 -->
				<!-- <view class="info-transverse">
					<view class="text3">支付方式</view>
					<radio-group name="" @change="payInput">
						<label v-for="item in identity" :key="item" style="margin-right:20px">
							<radio :value="item" :checked="item==payMethod" color="#EA5404"
								style="transform:scale(0.7)" />
							{{item}}
						</label>
					</radio-group>
				</view> -->
				<!-- #endif -->

				<view style="height: 200upx;"></view>



			</scroll-view>
		</view>


		<view class="info-pey">
			<view class="jurisdiction">
				<view>
					<checkbox-group @change="onCheckChange">
						<checkbox value="vvv" :checked="agreementChecked" v-model='agreementChecked'
							style="transform: scale(0.64);"></checkbox>
					</checkbox-group>
				</view>
				<view class="checkbox-test">
					我已阅读并同意
				</view>
				<view class="checkbox-test" @click="purchaseAgreement" style="color: #EA5404;">
					《购车协议》
				</view>

			</view>
			<!-- <view class="peyBtn" v-if="uniqueserverInfos==0" @click="peyBtn">支付定金</view>
			<view class="peyBtn" v-else @click="peyBtn">立即支付</view> -->
			
			
			
			<view class="payBtnGrey" v-if="payBtnGrey==true">支付定金</view>
			<view class="peyBtn" v-else @click="peyBtn">支付定金</view>
		</view>

		<purchaseAgreementPop :popupShow="popupShow" @closePop="closePop" ref="countDown"></purchaseAgreementPop>
		<morePicker :oneList="provinces" :twoList="citys" :defaultValue="defaultValue"
			@morePickerChange="morePickerChange" @closeMorePicker="closeMorePicker"
			@confirmMorePicker="confirmMorePicker" v-if="isShowPicker">
		</morePicker>


		<u-modal :show="warnShow" :content='warnContent' :confirmText='warnConfirmText' confirmColor='#EA5404'
			@confirm='createLevcCarOrder'></u-modal>



		<u-modal :show="showStagesStorePop" :content='showStagesContent' :confirmText='showStagesConfirmText' confirmColor='#EA5404'
			@confirm='confirmStages'></u-modal>
			
		<u-modal :show="showVersionPop" :content='showVersionContent' :confirmText='showVersionConfirmText' confirmColor='#EA5404'
			@confirm='showVersionPop=false'></u-modal>
 
	</view>
</template>

<script>
	const app = getApp();
	const network = require("@manager/network-manager.js")
	const util = require('@utils/util.js');
	import purchaseAgreementPop from '@/components/purchase-agreement-pop/purchase-agreement-pop.vue';
	import morePicker from '@/components/morePicker.vue'
	export default {
		components: {
			purchaseAgreementPop,
			morePicker
		},
		data() {
			return {
				userInfo: null,
				text: '订单确认',
				color: '#000000',
				// backgroundColor: 'rgba(0, 0, 0, 0)',
				backgroundColor: '#ffffff',
				payMethod: "",
				identity: ['微信', '支付宝'],
				paymentType: "",
				identityPeyType: [
					{value:'0',text:'全款支付'}, 
					{value:'1',text:'金融分期'}
				],
				// identityPeyType: ['全款支付'],
				popupShow: false,
				isReadAgreement: false,
				agreementChecked: false, //协议
				carSeriesEntity: null, //选中的车系实体
				carTypeEntity: null, //选中的车型实体
				configureEntity: null, //选中的配置实体
				colorEntity: null, //选中的颜色实体
				optionalEntity: null, //选中的选装包实体
				individuationEntity: null, //选中的个性化实体
				totlePrice: 0,
				name: "",
				mobile: "",
				idcard: '',
				store: '',
				address: "",
				depositAmount: 0,
				balancePayment: 0,
				seriesId: '',
				seriesName: '',
				modelId: "",
				modelName: '',
				configureId: '',
				carConfigName: '',
				configurePic: '',
				carConfigMoney: 0,
				colorPic:'',
				colorId: '',
				colorName: '',
				colorMoney: '',
				servciepkgInfos: [],
				uniqueserverInfos: [],
				provinces: [], //省
				citys: [], //市
				province: '',
				provinceCode: '',
				city: '',
				cityCode: '',
				defaultValue: [0, 0], //默认值
				isShowPicker: false,
				isShowStoresPicker: false,
				storesList: [],
				haveStoresList: false,
				storeName: '',
				storeId: '',

				//from 心愿单编辑、心愿单转订单、立即预定
				from: '',
				wishId: '',

				isWishEdit: false,
				warnShow: false,
				warnContent: '若订单状态变更为订单已审批，则您的车辆已进入排产阶段，将无法取消订单及退款',
				warnConfirmText: '我已知晓',

				showStagesStorePop: false,
				showStagesContent: '该城市下无可选门店，可更换城市或购车方式重新选择',
				showStagesConfirmText: '确定',
				payBtnGrey:false,
				
				showVersionPop: false,
				showVersionContent:'您的App版本过低，请在我的-设置-点击“当前版本”，升级为最新版本，再下单',
				showVersionConfirmText: '确定',



			}
		},
		created() {},


		onLoad(options) {
			var that = this;
			//#ifdef MP-WEIXIN
			that.payMethod == "微信"
			//#endif

			that.from = options.from
			if (that.from != "心愿单转订单") {

				if (that.from == "心愿单编辑") {
					this.wishId = options.wishId
					this.isWishEdit = options.isWishEdit
				} else {
					that.userInfo = app.globalData.userInfo
					that.name = that.userInfo.userName
					that.mobile = that.userInfo.phone
					that.getProvinceCityInfoByCityName(that.userInfo.city)
				}
				that.carSeriesEntity = JSON.parse(options.carSeriesJson);
				that.carTypeEntity = JSON.parse(options.carTypeJson);
				that.configureEntity = JSON.parse(options.configureJson);
				that.colorEntity = JSON.parse(options.colorJson);
				if (options.optionalJson != null) {
					that.optionalEntity = JSON.parse(options.optionalJson);
				}
				if (options.individuationJson != null) {
					that.individuationEntity = JSON.parse(options.individuationJson);
				}
				//总计
				that.totlePrice = options.totlePrice
				//车系
				that.seriesId = that.carSeriesEntity.uuid
				that.seriesName = that.carSeriesEntity.seriesName
				//车型
				that.modelId = that.carTypeEntity.uuid
				that.modelName = that.carTypeEntity.modelName
				//配置
				that.configureId = that.configureEntity.id
				that.carConfigName = that.configureEntity.carConfigName
				that.configurePic = that.configureEntity.carImgUrl
				that.carConfigMoney = that.configureEntity.carConfigMoney

				//颜色
				debugger
				that.colorPic = that.colorEntity.configureImg
				that.colorId = that.colorEntity.id
				that.colorName = that.colorEntity.colorName
				that.colorMoney = that.colorEntity.colorPrice
				//选装包
				if (that.optionalEntity != null) {
					var servciepkgInfoItem = {}
					servciepkgInfoItem.serverName = that.optionalEntity.packageName
					servciepkgInfoItem.uniqueContent = ""
					servciepkgInfoItem.serverMoney = that.optionalEntity.packagePrice
					servciepkgInfoItem.type = 1
					servciepkgInfoItem.serverId = that.optionalEntity.id
					servciepkgInfoItem.packageDescribe = that.optionalEntity.packageDescribe
					servciepkgInfoItem.packageDescribeList = that.optionalEntity.packageDescribeList
					that.servciepkgInfos.push(servciepkgInfoItem)
				}
				//个性化
				if (that.individuationEntity != null) {
					var uniqueserverInfoItem = {}
					uniqueserverInfoItem.serverName = that.individuationEntity.serverName
					uniqueserverInfoItem.uniqueContent = that.individuationEntity.uniqueContent
					uniqueserverInfoItem.serverMoney = that.individuationEntity.serverPrice
					uniqueserverInfoItem.type = 2
					uniqueserverInfoItem.serverId = that.individuationEntity.id
					that.uniqueserverInfos.push(uniqueserverInfoItem)
				}
				that.getLevcCarOrderDepositAmount(that.modelId)
			} else {
				this.wishId = options.wishId
				that.getWishDetail(that.wishId)
			}

			
			that.getProvinces()
			if (this.isWishEdit == 'true') {
				that.updateWishList()
			}



		},

		watch: {

		},
		methods: {
			//根据cityName查询对应信息
			getProvinceCityInfoByCityName: function(city) {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GET_PROVINCE_CITY_INFO_BY_CITYNAME;
				var params = {
					"cityName": city
				}
				console.log(params, 'params')
				network.get(uri, params, 'json').then(res => {
					if (res.code == 200) {
						this.provinceCode = res.data.provinceCode
						this.cityCode = res.data.cityCode
						this.city = res.data.cityName
						// this.getStoresListByCity()
						if (this.paymentType == '1') {
							//金融分期
							this.getStagesStoreList()
						} else {
							//全款
							this.getStoresListByCity()
						}
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				}).catch(res => {

				});
			},

			//输入监听
			inputValueChange(e) {
				let type = e.currentTarget.dataset.type
				let value = e.detail.value
				if (value == '') {
					this.forbidden = true
				} 
				
				
				// else {
				// 	this.isForbidden()
				// }
				if (type == 'mobile') {
					value = Number(value.toString().match(/^\d+(?:\.\d{0,2})?/)[0])
					this.$nextTick(() => {
						this.formData[type] = value
					})
				}
			},
			//地址选择变化	
			morePickerChange(e) {
				const val = e.detail.value;
				if (this.defaultValue[0] !== val[0]) {
					// this.defaultValue = [val[0],0,0];//省变，后面的都默认选第一个
					this.defaultValue = [val[0], 0]; //省变，后面的都默认选第一个
					this.getProvinces();
				} else if (this.defaultValue[1] !== val[1]) {
					// this.defaultValue = [val[0],val[1],0];//市变，后面的默认第一个
					this.defaultValue = [val[0], val[1]]; //市变，后面的默认第一个
					this.getCitys();
				} else {
					this.defaultValue = val;
				}
			},
			//取消选取
			closeMorePicker() {
				this.isShowPicker = false;
			},
			//确认选取
			confirmMorePicker() {
				this.isShowPicker = false;
				//省
				if (this.provinces[this.defaultValue[0]].id) {
					this.province = this.provinces[this.defaultValue[0]].provinceName;
					this.provinceCode = this.provinces[this.defaultValue[0]].provinceCode;
				}
				//市
				if (this.citys[this.defaultValue[1]].id) {
					this.city = this.citys[this.defaultValue[1]].cityName;
					this.cityCode = this.citys[this.defaultValue[1]].cityCode;

					this.storesList = []
					this.storeName = ''
					if (this.paymentType == '1') {
						//金融分期
						this.getStagesStoreList()
					} else {
						//全款
						this.getStoresListByCity()
					}
				}

			},
			//获取省接口
			getProvinces: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GET_PROVINCE;
				var params = {
					"loginId": app.getUserId()
				}
				console.log(params, 'params')
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.provinces = res.data.ProvinceList
						this.getCitys();
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				}).catch(res => {

				});
			},
			//获取市
			getCitys: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GET_CITY_BY_PROVINCE;
				var params = {
					"loginId": app.getUserId(),
					"provinceCode": this.provinces[this.defaultValue[0]].provinceCode
				}
				console.log(params, 'params')
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.citys = res.data.cityList
					} else {
						setTimeout(() => {
							uni.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							})
						}, 500)
					}
				}).catch(res => {

				});
			},
			//心愿单详细
			getWishDetail: function(wishId) {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_CAR_WISH_GET;
				var params = {
					"id": wishId,
					"loginId": app.getUserId()
				}
				console.log(params, 'params')
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						//总计
						that.totlePrice = res.data.orderAmount
						//车系
						that.seriesId = res.data.seriesId
						that.seriesName = res.data.seriesName
						//车型
						that.modelId = res.data.modelId
						that.modelName = res.data.modelName
						//配置
						that.configureId = res.data.modelConfigureId
						that.carConfigName = res.data.modelConfigureName
						that.configurePic = res.data.configurePic
						that.carConfigMoney = res.data.modelConfigureMoney
						//颜色
						that.colorId = res.data.colorId
						that.colorName = res.data.colorName
						that.colorMoney = res.data.colorMoney
						//选装包
						that.servciepkgInfos = res.data.servicepkgInfos
						//个性化
						that.uniqueserverInfos = res.data.uniqueserverInfos
						that.getLevcCarOrderDepositAmount(that.modelId)
					} else {
						setTimeout(() => {
							uni.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							})
						}, 500)
					}
				}).catch(res => {

				});
			},
			//获取支付定金金额
			getLevcCarOrderDepositAmount: function(modelId) {
				debugger
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GET_AMOUNT;
				var params = {'modelId':modelId}
				console.log(params, 'params')
				network.get(uri, params, 'json').then(res => {
					if (res.code == 200) {
						that.depositAmount = res.data
						that.balancePayment = that.totlePrice - that.depositAmount
					} else {
						//#ifdef MP-WEIXIN
							setTimeout(() => {
								uni.showToast({
									title: res.message,
									duration: 3000,
									icon: 'none'
								})
							}, 500)
						//#endif
						
						//#ifdef APP-PLUS || H5
							that.showVersionPop=true
						//#endif
					}
				}).catch(res => {});

			},
			//加入心愿单
			addWishList: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_CAR_WISH_CREATE;
				var params = {
					"userId": app.getUserId(),
					"seriesId": that.seriesId,
					"seriesName": that.seriesName,

					"modelId": that.modelId,
					"modelName": that.modelName,

					"modelConfigureId": that.configureId,
					"modelConfigureName": that.carConfigName,
					// "configurePic": that.configurePic,
					"configurePic": that.colorPic,
					"modelConfigureMoney": that.carConfigMoney,

					"orderAmount": that.totlePrice,

					"colorId": that.colorId,
					"colorName": that.colorName,
					"colorMoney": that.colorMoney,

					"servicepkgInfos": that.servciepkgInfos,

					"uniqueserverInfos": that.uniqueserverInfos
				};
				console.log(params, 'params')
				network.post(uri, params, 'json').then(res => {
					if (res.code == 200) {
						that.wishId = res.data
						setTimeout(() => {
							uni.showToast({
								title: "操作成功",
								duration: 3000,
								icon: 'none'
							})
						}, 500)
					} else {
						setTimeout(() => {
							uni.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							})
						}, 500)
					}
				}).catch(res => {});

			},
			//更新心愿单
			updateWishList: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_CAR_WISH_UPDATE;
				var params = {
					"id": that.wishId,
					"userId": app.getUserId(),
					"seriesId": that.seriesId,
					"seriesName": that.seriesName,

					"modelId": that.modelId,
					"modelName": that.modelName,

					"modelConfigureId": that.configureId,
					"modelConfigureName": that.carConfigName,
					"configurePic": that.configurePic,
					"modelConfigureMoney": that.carConfigMoney,

					"orderAmount": that.totlePrice,

					"colorId": that.colorId,
					"colorName": that.colorName,
					"colorMoney": that.colorMoney,

					"servicepkgInfos": that.servciepkgInfos,

					"uniqueserverInfos": that.uniqueserverInfos
				};
				console.log(params, 'params')
				network.post(uri, params, 'json').then(res => {
					if (res.code == 200) {
						that.wishId = res.data
						setTimeout(() => {
							wx.showToast({
								title: "操作成功",
								duration: 3000,
								icon: 'none'
							});
						}, 500);
					} else {
						setTimeout(() => {
							wx.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							});
						}, 500);

					}
				}).catch(res => {});
			},
			//取消心愿单
			deleteWishList: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_CAR_WISH_DELETE;
				var params = {
					"id": that.wishId
				};
				console.log(params, 'params')
				network.post(uri, params, 'form').then(res => {
					if (res.code == 200) {
						that.wishId = ""
						setTimeout(() => {
							wx.showToast({
								title: "操作成功",
								duration: 3000,
								icon: 'none'
							});
						}, 500);

					} else {
						setTimeout(() => {
							wx.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							});
						}, 500);
					}
				}).catch(res => {});

			},
			//确定金融分期警告
			confirmStages:function(){
				this.showStagesStorePop=false
				this.payBtnGrey = true
			},
			//创建订单
			createLevcCarOrder: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_CREATE_CARORDER;
				var configure = {
					"userId": app.getUserId(),
					"changeFlag": 1,
					"colorId": that.colorId,
					"colorMoney": that.colorMoney,
					"colorName": that.colorName,
					"configurePic": that.configurePic,
					"modelConfigureId": that.configureId,
					"modelConfigureMoney": that.carConfigMoney,
					"modelConfigureName": that.carConfigName,
					"modelId": that.modelId,
					"modelName": that.modelName,
					"orderAmount": that.totlePrice,
					"seriesId": that.seriesId,
					"seriesName": that.seriesName,
					"servicepkgInfos": that.servciepkgInfos,
					"uniqueserverInfos": that.uniqueserverInfos


				};

				var depositPaymentFlag = ""
				var paymentFlag = ""
				var depositAmount = ''
				var finalAmount = ""
				// if (that.uniqueserverInfos.length == 0) {
				// 	depositAmount = that.depositAmount
				// 	if (that.payMethod == "微信") {
				// 		depositPaymentFlag = 1
				// 	} else if (that.payMethod == "支付宝") {
				// 		depositPaymentFlag = 2
				// 	}
				// } else {
				// 	finalAmount = that.totlePrice
				// 	if (that.payMethod == "微信") {
				// 		paymentFlag = 1
				// 	} else if (that.payMethod == "支付宝") {
				// 		paymentFlag = 2
				// 	}
				// }


				depositAmount = that.depositAmount
				if (that.payMethod == "微信") {
					depositPaymentFlag = 1
				} else if (that.payMethod == "支付宝") {
					depositPaymentFlag = 2
				}

				var fromFlag = ""
				//#ifdef MP-WEIXIN
				fromFlag = 3
				//#endif
				//#ifdef APP-PLUS || H5
				fromFlag = 4
				//#endif

				var params = {
					"userId": app.getUserId(),
					"buyAddress": that.address,
					"buyCard": that.idcard,
					"buyName": that.name,
					"buyPhone": that.mobile,
					"city": that.cityCode,
					"configure": configure,
					"depositAmount": depositAmount,
					// "depositPaymentFlag": depositPaymentFlag,
					// "finalAmount": finalAmount,
					"fromFlag": fromFlag,
					"orderAmount": that.totlePrice,
					"orderConfigureId": that.wishId,
					"orderFlag": 1,
					// "paymentFlag": paymentFlag,
					"province": that.provinceCode,
					"statusFlag": 0,
					"storeName": that.storeName,
					"storeId": that.storeId,
					"paymentType": that.paymentType,
				}

				console.log(params, 'params')
				network.post(uri, params, 'json', null, true).then(res => {
					if (res.code == 200) {
						var money = that.depositAmount
						var currentPayType = 1
						// if (that.uniqueserverInfos.length == 0) {
						// 	money = that.depositAmount
						// 	currentPayType = 1
						// } else {
						// 	money = that.totlePrice
						// 	currentPayType = 2
						// }
						
						//五期
						uni.redirectTo({
							url: '/module_my/pages/orderList/payment/payment?id=' + res.data.id +
								"&money=" + money + "&currentPayType=" + currentPayType +
								"&expireTime=" + res.data.expireTime +
								"&from=orderList"
						})
						
						//四期
						// uni.redirectTo({
						// 	url: '/module_my/pages/orderList/payment/payment?id=' + res.data +
						// 		"&money=" + money + "&currentPayType=" + currentPayType +
						// 		//"&expireTime=" + res.data.expireTime +
						// 		"&from=orderList"
						// })

						// //#ifdef APP-PLUS||H5
						// wx.showToast({
						// 	title: res.message,
						// 	duration: 3000,
						// 	icon: 'none'
						// });
						// that.payOrder(res.data)
						// //#endif
						// //#ifdef MP-WEIXIN
						// setTimeout(() => {
						// 	wx.showToast({
						// 		title: res.message,
						// 		duration: 3000,
						// 		icon: 'none'
						// 	});
						// }, 500);
						// that.payOrderForWXMiniApp(res.data)
						// //#endif







					} else {
						that.warnShow = false
						setTimeout(() => {
							wx.showToast({
								title: res.message,
								duration: 3000,
								icon: 'none'
							});
						}, 500);
					}
				}).catch(res => {});

			},
			//支付订单
			payOrder(orderId) {
				var that = this

				var payType = "" //payType   支付宝01、微信支付02
				if (that.payMethod == "微信") {
					payType = "02"
				} else if (that.payMethod == "支付宝") {
					payType = "01"
				}
				let params = {
					paymentChannel: payType,
					outTradeNo: orderId,
					// goodsDescription: `派方摩托车${this.uniqueserverInfos.length == 0 ? '定金': '订单'}支付`,
					goodsDescription: `派方摩托车定金支付`,
					paymentChannelSubclass: payType
				};
				let url = app.globalData.config.interfaces.URL_PAYMENT_ALL;

				network.post(url, params, 'json', null, true).then(res => {
					console.log(res)
					let data = {
						appid: res.appId,
						noncestr: res.nonceStr,
						package: res.package,
						partnerid: res.partnerId,
						prepayid: res.prepayId,
						timestamp: res.timeStamp + '',
						sign: res.sign
					}

					let order = params.paymentChannel === '01' ? (res.orderString + '&sign=' + res.sign) : data;
					console.log("submit order:" + params.paymentChannel === '01' ? order : JSON.stringify(order));
					if (res) {
						uni.requestPayment({
							provider: params.paymentChannel === '01' ? 'alipay' : 'wxpay',
							orderInfo: order,
							success: function(res) {
								console.log("requestPayment success" + JSON.stringify(res));
								if (res.errMsg === "requestPayment:ok") {
									uni.navigateTo({
										url: '/module_my/pages/orderList/orderList'
									})
								}
							},
							fail: function(err) {
								console.log("requestPayment err" + JSON.stringify(res));
								dialog.toast("支付失败");
								uni.navigateTo({
									url: '/module_my/pages/orderList/orderList'
								})
							},
							complete: function(e) {
								console.log("requestPayment complete" + JSON.stringify(e));

							}
						});
					}
				})
			},
			//微信小程序支付
			payOrderForWXMiniApp: function(orderId) {
				var payType = "02" //payType   支付宝01、微信支付02
				let params = {
					paymentChannel: payType,
					openid: uni.getStorageSync('openId'),
					outTradeNo: orderId,
					// goodsDescription: `派方摩托车${this.uniqueserverInfos.length == 0 ? '定金': '订单'}支付`,
					goodsDescription: `派方摩托车定金支付`,
					paymentChannelSubclass: payType,
				};
				let url = app.globalData.config.interfaces.URL_PAYMENT;

				network.post(url, params, 'json', null, true).then(res => {
					console.log(res)
					let data = {
						appid: res.appId,
						noncestr: res.nonceStr,
						package: res.package,
						partnerid: res.partnerId,
						prepayid: res.prepayId,
						timestamp: res.timeStamp + '',
						sign: res.sign
					}

					let order = params.paymentChannel === '01' ? (res.orderString + '&sign=' + res.sign) :
						data;
					console.log("submit order:" + params.paymentChannel === '01' ? order : JSON.stringify(
						order));
					if (res) {
						uni.requestPayment({
							appid: res.appId,
							timeStamp: res.timeStamp + '',
							nonceStr: res.nonceStr,
							package: res.package,
							paySign: res.paySign,
							signType: 'MD5',
							success: function(res) {
								console.log("requestPayment success" + JSON.stringify(res));
								if (res.errMsg === "requestPayment:ok") {
									uni.navigateTo({
										url: '/module_my/pages/orderList/orderList'
									})
								}
							},
							fail: function(err) {
								console.log("requestPayment err" + JSON.stringify(res));
								setTimeout(() => {
									wx.showToast({
										title: "支付失败",
										duration: 3000,
										icon: 'none'
									});
								}, 500);
								uni.navigateTo({
									url: '/module_my/pages/orderList/orderList'
								})
							},
							complete: function(e) {
								console.log("requestPayment complete" + JSON.stringify(e));
							}
						})
					}
				})
			},
			// 轮询查询订单支付状态
			pollingOrderStatus() {
				uni.navigateTo({
					url: '/module_my/pages/orderList/orderList'
				})
				this.hide = false
			},
			//点击购车协议
			purchaseAgreement: function() {
				this.popupShow = true
				this.$refs.countDown.timer()
				this.isReadAgreement = true
			},
			//关闭购车协议pop
			closePop: function() {
				this.popupShow = false
			},
			//勾选购车协议
			onCheckChange: function(e) {
				var that = this;
				that.agreementChecked = e.detail.value.length > 0;
				if (that.agreementChecked == true) {
					//如果勾选却没有阅读购车协议，弹出购车协议
					if (that.isReadAgreement == false) {
						that.purchaseAgreement()
					}
				}
			},
			payInput: function(e) {
				if (e.detail.value == '1') {
					this.paymentType = '1'
					this.getStagesStoreList()
				} else {
					this.paymentType = '0'
					this.getStoresListByCity()
					this.payBtnGrey = false
				}
			},
			//点击支付按钮
			peyBtn: function() {
				var that = this;
				if (that.agreementChecked == false) {
					uni.showToast({
						title: "请查看并同意协议后继续",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.paymentType == '') {
					uni.showToast({
						title: "请选择金融信息",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.name == '') {
					uni.showToast({
						title: "请输入姓名",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.mobile == '') {
					uni.showToast({
						title: "请输入手机号",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.mobile.length != 11) {
					uni.showToast({
						title: "请输入正确的手机号",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.mobile.substring(0, 1) != "1") {
					uni.showToast({
						title: "请输入正确的手机号",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.idcard == '') {
					uni.showToast({
						title: "请输入身份证号",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.idcard.length != 18) {
					uni.showToast({
						title: "请输入正确的身份证号",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.city == '') {
					uni.showToast({
						title: "请选择所在地区",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.haveStoresList == true && that.storeName == '') {
					uni.showToast({
						title: "请选择购车门店",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.address == '') {
					uni.showToast({
						title: "请输入详细地址",
						duration: 3000,
						icon: 'none'
					})
				} else if (that.address.length > 150) {
					uni.showToast({
						title: "地址最多可填写150字符",
						duration: 3000,
						icon: 'none'
					})
				} else {
					that.warnShow = true
					// that.createLevcCarOrder()
				}
			},

			//跳转所在区域
			toArea: function() {
				this.isShowPicker = true
			},
			//分期用的根据城市查门店
			getStagesStoreList: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GETSTAGESSTORELIST;
				var params = {
					"isCity": that.cityCode,
					"dictionaryCode": 'LEVC_STORE_AREA',
					"contentCode": '008'
				}
				console.log(params, 'params')
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						var list = res.data
						if (list.length > 0) {
							that.haveStoresList = true
							that.storesList = [res.data]
							this.payBtnGrey = false
						} else {
							that.haveStoresList = false

							that.showStagesStorePop = true



						}
					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				}).catch(res => {

				});

			},
			//根据城市查询门店
			getStoresListByCity: function() {
				var that = this;
				var uri = app.globalData.config.interfaces.URL_GETSTAGESSTORELIST;
				var params = {
					"isCity": that.cityCode,
					"dictionaryCode": 'LEVC_STORE_AREA',
					"contentCode": '003'
				}
				console.log(params, 'params')
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						var list = res.data
						if (list.length > 0) {
							that.haveStoresList = true
							that.storesList = [res.data]
						} else {
							that.haveStoresList = false
						}



					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}
				}).catch(res => {

				});

			},
			//展示门店滚轮
			showStoresData: function() {
				this.isShowStoresPicker = true
			},
			//确定-选择下拉框
			confirmPicker: function(e) {
				if (this.isShowStoresPicker == true) {
					this.isShowStoresPicker = false
					this.storeName = e.value[0].storeName
					this.storeId = e.value[0].uuid
				}

			},
			//取消-下拉框
			cancelPicker: function() {
				if (this.isShowStoresPicker == true) {
					this.isShowStoresPicker = false
				}

			},


		}
	}
</script>

<style lang="less">
	@import "./orderConfirm.css";
</style>
